package unplag;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.*;
import java.io.*;
import unplag.core.BaseDir;
import unplag.core.FileFormat;
import unplag.core.ProgressListener;
import unplag.core.Work;
import unplag.engine.*;
/**
 *
 * @author Naruil
 */

public class Main {

    /**
     * @param args the command line arguments
     */


    public static void getLCString(char[] str1, char[] str2)
    {
        int i,j;
        int len1,len2;
        len1 = str1.length;
        len2 = str2.length;
        int maxLen = len1 > len2?len1:len2;
        int[] max = new int[maxLen];
        int[] maxIndex = new int[maxLen];
        int[] c = new int[maxLen];

        for (i = 0; i < len2 ; i++){
            for (j = len1 -1; j >= 0; j--){
                if (str2[i] == str1[j]){
                    if ( ( i == 0) || (j == 0) )
                        c[j] = 1;
                    else
                        c[j] = c[j-1] + 1;
                }else{
                    c[j] = 0;
                }

                if (c[j] > max[0]){
                    max[0] = c[j];
                    maxIndex[0] = j;

                    for (int k = 1; k < maxLen; k++){
                        max[k] = 0;
                        maxIndex[k] = 0;
                    }
                }else if (c[j] == max[0]){
                    for (int k = 1; k < maxLen; k++){
                        if (max[k] == 0){
                            max[k] = c[j];
                            maxIndex[k] = j;
                            break;
                        }

                    }
                }
            }
        }

        for (j = 0; j < maxLen; j++){
            if (max[j] > 0){
                System.out.println("第" + (j + 1) + "个公共子串:");
                for (i = maxIndex[j] - max[j] + 1; i <= maxIndex[j]; i++)
                    System.out.print(str1[i]);
                System.out.println(" ");
            }
        }
    }




    public static void main(String[] args){
        BaseDir ws=new BaseDir("D:\\ac\\sample_oop");
        System.out.println(ws.getWorks());
        ws.addFileFormat(new FileFormat("C Source File","c"));
        ws.addFileFormat(new FileFormat("Java Source File","java"));
        ws.addFileFormat(new FileFormat("C Header File","h"));
        ProgressListener pl=new ProgressListener(){
            public void report(int percent) {
                System.out.println(percent);
            }
        };
        ws.setProgressListener(pl);
        ws.scanFile();
        System.out.println(ws.getTargetFiles());
        
    }
}
